.TH "TCRDB" 3 "2010-08-05" "Man Page" "Tokyo Tyrant"

.SH NAME
tcrdb \- the remote database API

.SH DESCRIPTION
.PP
Remote database is a set of interfaces to use an abstract database of Tokyo Cabinet, mediated by a server of Tokyo Tyrant.
.PP
.PP
To use the remote database API, include `\fBtcrdb.h\fR' and related standard header files.  Usually, write the following description near the front of a source file.
.PP
.RS
.br
\fB#include <tcrdb.h>\fR
.br
\fB#include <stdlib.h>\fR
.br
\fB#include <stdbool.h>\fR
.br
\fB#include <stdint.h>\fR
.RE
.PP
Objects whose type is pointer to `\fBTCRDB\fR' are used to handle remote databases.  a remote database object is created with the function `\fBtcrdbnew\fR' and is deleted with the function `\fBtcrdbdel\fR'.  To avoid memory leak, it is important to delete every object when it is no longer in use.
.PP
Before operations to store or retrieve records, it is necessary to connect the remote database object to the server.  The function `\fBtcrdbopen\fR' is used to open a database connection and the function `\fBtcrdbclose\fR' is used to close the connection.

.SH DESCRIPTION
.PP
The function `tcrdberrmsg' is used in order to get the message string corresponding to an error code.
.PP
.RS
.br
\fBconst char *tcrdberrmsg(int \fIecode\fB);\fR
.RS
`\fIecode\fR' specifies the error code.
.RE
.RS
The return value is the message string of the error code.
.RE
.RE
.PP
The function `tcrdbnew' is used in order to create a remote database object.
.PP
.RS
.br
\fBTCRDB *tcrdbnew(void);\fR
.RS
The return value is the new remote database object.
.RE
.RE
.PP
The function `tcrdbdel' is used in order to delete a remote database object.
.PP
.RS
.br
\fBvoid tcrdbdel(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RE
.PP
The function `tcrdbecode' is used in order to get the last happened error code of a remote database object.
.PP
.RS
.br
\fBint tcrdbecode(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
The return value is the last happened error code.
.RE
.RS
The following error code is defined: `TTESUCCESS' for success, `TTEINVALID' for invalid operation, `TTENOHOST' for host not found, `TTEREFUSED' for connection refused, `TTESEND' for send error, `TTERECV' for recv error, `TTEKEEP' for existing record, `TTENOREC' for no record found, `TTEMISC' for miscellaneous error.
.RE
.RE
.PP
The function `tcrdbtune' is used in order to set the tuning parameters of a hash database object.
.PP
.RS
.br
\fBbool tcrdbtune(TCRDB *\fIrdb\fB, double \fItimeout\fB, int \fIopts\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fItimeout\fR' specifies the timeout of each query in seconds.  If it is not more than 0, the timeout is not specified.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBTRECON' specifies that the connection is recovered automatically when it is disconnected.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
Note that the tuning parameters should be set before the database is opened.
.RE
.RE
.PP
The function `tcrdbopen' is used in order to open a remote database.
.PP
.RS
.br
\fBbool tcrdbopen(TCRDB *\fIrdb\fB, const char *\fIhost\fB, int \fIport\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIhost\fR' specifies the name or the address of the server.
.RE
.RS
`\fIport\fR' specifies the port number.  If it is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbopen2' is used in order to open a remote database with a simple server expression.
.PP
.RS
.br
\fBbool tcrdbopen2(TCRDB *\fIrdb\fB, const char *\fIexpr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIexpr\fR' specifies the simple server expression.  It is composed of two substrings separated by ":".  The former field specifies the name or the address of the server.  The latter field specifies the port number.  If the latter field is omitted, the default port number is specified.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbclose' is used in order to close a remote database object.
.PP
.RS
.br
\fBbool tcrdbclose(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbput' is used in order to store a record into a remote database object.
.PP
.RS
.br
\fBbool tcrdbput(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIvbuf\fR' specifies the pointer to the region of the value.
.RE
.RS
`\fIvsiz\fR' specifies the size of the region of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, it is overwritten.
.RE
.RE
.PP
The function `tcrdbput2' is used in order to store a string record into a remote object.
.PP
.RS
.br
\fBbool tcrdbput2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
`\fIvstr\fR' specifies the string of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, it is overwritten.
.RE
.RE
.PP
The function `tcrdbputkeep' is used in order to store a new record into a remote database object.
.PP
.RS
.br
\fBbool tcrdbputkeep(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIvbuf\fR' specifies the pointer to the region of the value.
.RE
.RS
`\fIvsiz\fR' specifies the size of the region of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, this function has no effect.
.RE
.RE
.PP
The function `tcrdbputkeep2' is used in order to store a new string record into a remote database object.
.PP
.RS
.br
\fBbool tcrdbputkeep2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
`\fIvstr\fR' specifies the string of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, this function has no effect.
.RE
.RE
.PP
The function `tcrdbputcat' is used in order to concatenate a value at the end of the existing record in a remote database object.
.PP
.RS
.br
\fBbool tcrdbputcat(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIvbuf\fR' specifies the pointer to the region of the value.
.RE
.RS
`\fIvsiz\fR' specifies the size of the region of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If there is no corresponding record, a new record is created.
.RE
.RE
.PP
The function `tcrdbputcat2' is used in order to concatenate a string value at the end of the existing record in a remote database object.
.PP
.RS
.br
\fBbool tcrdbputcat2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
`\fIvstr\fR' specifies the string of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If there is no corresponding record, a new record is created.
.RE
.RE
.PP
The function `tcrdbputshl' is used in order to concatenate a value at the end of the existing record and shift it to the left.
.PP
.RS
.br
\fBbool tcrdbputshl(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB, int \fIwidth\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIvbuf\fR' specifies the pointer to the region of the value.
.RE
.RS
`\fIvsiz\fR' specifies the size of the region of the value.
.RE
.RS
`\fIwidth\fR' specifies the width of the record.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If there is no corresponding record, a new record is created.
.RE
.RE
.PP
The function `tcrdbputshl2' is used in order to concatenate a string value at the end of the existing record and shift it to the left.
.PP
.RS
.br
\fBbool tcrdbputshl2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB, int \fIwidth\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
`\fIvstr\fR' specifies the string of the value.
.RE
.RS
`\fIwidth\fR' specifies the width of the record.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If there is no corresponding record, a new record is created.
.RE
.RE
.PP
The function `tcrdbputnr' is used in order to store a record into a remote database object without response from the server.
.PP
.RS
.br
\fBbool tcrdbputnr(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIvbuf\fR' specifies the pointer to the region of the value.
.RE
.RS
`\fIvsiz\fR' specifies the size of the region of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, it is overwritten.
.RE
.RE
.PP
The function `tcrdbputnr2' is used in order to store a string record into a remote object without response from the server.
.PP
.RS
.br
\fBbool tcrdbputnr2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
`\fIvstr\fR' specifies the string of the value.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, it is overwritten.
.RE
.RE
.PP
The function `tcrdbout' is used in order to remove a record of a remote database object.
.PP
.RS
.br
\fBbool tcrdbout(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbout2' is used in order to remove a string record of a remote database object.
.PP
.RS
.br
\fBbool tcrdbout2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbget' is used in order to retrieve a record in a remote database object.
.PP
.RS
.br
\fBvoid *tcrdbget(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, int *\fIsp\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIsp\fR' specifies the pointer to the variable into which the size of the region of the return value is assigned.
.RE
.RS
If successful, the return value is the pointer to the region of the value of the corresponding record.  `NULL' is returned if no record corresponds.
.RE
.RS
Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.  Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbget2' is used in order to retrieve a string record in a remote database object.
.PP
.RS
.br
\fBchar *tcrdbget2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
If successful, the return value is the string of the value of the corresponding record.  `NULL' is returned if no record corresponds.
.RE
.RS
Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbget3' is used in order to retrieve records in a remote database object.
.PP
.RS
.br
\fBbool tcrdbget3(TCRDB *\fIrdb\fB, TCMAP *\fIrecs\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIrecs\fR' specifies a map object containing the retrieval keys.  As a result of this function, keys existing in the database have the corresponding values and keys not existing in the database are removed.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbvsiz' is used in order to get the size of the value of a record in a remote database object.
.PP
.RS
.br
\fBint tcrdbvsiz(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
If successful, the return value is the size of the value of the corresponding record, else, it is \-1.
.RE
.RE
.PP
The function `tcrdbvsiz2' is used in order to get the size of the value of a string record in a remote database object.
.PP
.RS
.br
\fBint tcrdbvsiz2(TCRDB *\fIrdb\fB, const char *\fIkstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
If successful, the return value is the size of the value of the corresponding record, else, it is \-1.
.RE
.RE
.PP
The function `tcrdbiterinit' is used in order to initialize the iterator of a remote database object.
.PP
.RS
.br
\fBbool tcrdbiterinit(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
The iterator is used in order to access the key of every record stored in a database.
.RE
.RE
.PP
The function `tcrdbiternext' is used in order to get the next key of the iterator of a remote database object.
.PP
.RS
.br
\fBvoid *tcrdbiternext(TCRDB *\fIrdb\fB, int *\fIsp\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIsp\fR' specifies the pointer to the variable into which the size of the region of the return value is assigned.
.RE
.RS
If successful, the return value is the pointer to the region of the next key, else, it is `NULL'.  `NULL' is returned when no record is to be get out of the iterator.
.RE
.RS
Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.  Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.  The iterator can be updated by multiple connections and then it is not assured that every record is traversed.
.RE
.RE
.PP
The function `tcrdbiternext2' is used in order to get the next key string of the iterator of a remote database object.
.PP
.RS
.br
\fBchar *tcrdbiternext2(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
If successful, the return value is the string of the next key, else, it is `NULL'.  `NULL' is returned when no record is to be get out of the iterator.
.RE
.RS
Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.  The iterator can be updated by multiple connections and then it is not assured that every record is traversed.
.RE
.RE
.PP
The function `tcrdbfwmkeys' is used in order to get forward matching keys in a remote database object.
.PP
.RS
.br
\fBTCLIST *tcrdbfwmkeys(TCRDB *\fIrdb\fB, const void *\fIpbuf\fB, int \fIpsiz\fB, int \fImax\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpbuf\fR' specifies the pointer to the region of the prefix.
.RE
.RS
`\fIpsiz\fR' specifies the size of the region of the prefix.
.RE
.RS
`\fImax\fR' specifies the maximum number of keys to be fetched.  If it is negative, no limit is specified.
.RE
.RS
The return value is a list object of the corresponding keys.  This function does never fail.  It returns an empty list even if no key corresponds.
.RE
.RS
Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbfwmkeys2' is used in order to get forward matching string keys in a remote database object.
.PP
.RS
.br
\fBTCLIST *tcrdbfwmkeys2(TCRDB *\fIrdb\fB, const char *\fIpstr\fB, int \fImax\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpstr\fR' specifies the string of the prefix.
.RE
.RS
`\fImax\fR' specifies the maximum number of keys to be fetched.  If it is negative, no limit is specified.
.RE
.RS
The return value is a list object of the corresponding keys.  This function does never fail.  It returns an empty list even if no key corresponds.
.RE
.RS
Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbaddint' is used in order to add an integer to a record in a remote database object.
.PP
.RS
.br
\fBint tcrdbaddint(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, int \fInum\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fInum\fR' specifies the additional value.
.RE
.RS
If successful, the return value is the summation value, else, it is `INT_MIN'.
.RE
.RS
If the corresponding record exists, the value is treated as an integer and is added to.  If no record corresponds, a new record of the additional value is stored.
.RE
.RE
.PP
The function `tcrdbadddouble' is used in order to add a real number to a record in a remote database object.
.PP
.RS
.br
\fBdouble tcrdbadddouble(TCRDB *\fIrdb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, double \fInum\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fInum\fR' specifies the additional value.
.RE
.RS
If successful, the return value is the summation value, else, it is Not\-a\-Number.
.RE
.RS
If the corresponding record exists, the value is treated as a real number and is added to.  If no record corresponds, a new record of the additional value is stored.
.RE
.RE
.PP
The function `tcrdbext' is used in order to call a function of the script language extension.
.PP
.RS
.br
\fBvoid *tcrdbext(TCRDB *\fIrdb\fB, const char *\fIname\fB, int \fIopts\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB, int *\fIsp\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIname\fR' specifies the function name.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.
.RE
.RS
`\fIkbuf\fR' specifies the pointer to the region of the key.
.RE
.RS
`\fIksiz\fR' specifies the size of the region of the key.
.RE
.RS
`\fIvbuf\fR' specifies the pointer to the region of the value.
.RE
.RS
`\fIvsiz\fR' specifies the size of the region of the value.
.RE
.RS
`\fIsp\fR' specifies the pointer to the variable into which the size of the region of the return value is assigned.
.RE
.RS
If successful, the return value is the pointer to the region of the value of the response.  `NULL' is returned on failure.
.RE
.RS
Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string.  Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbext2' is used in order to call a function of the script language extension with string parameters.
.PP
.RS
.br
\fBchar *tcrdbext2(TCRDB *\fIrdb\fB, const char *\fIname\fB, int \fIopts\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIname\fR' specifies the function name.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.
.RE
.RS
`\fIkstr\fR' specifies the string of the key.
.RE
.RS
`\fIvstr\fR' specifies the string of the value.
.RE
.RS
If successful, the return value is the string of the value of the response.  `NULL' is returned on failure.
.RE
.RS
Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbsync' is used in order to synchronize updated contents of a remote database object with the file and the device.
.PP
.RS
.br
\fBbool tcrdbsync(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdboptimize' is used in order to optimize the storage of a remove database object.
.PP
.RS
.br
\fBbool tcrdboptimize(TCRDB *\fIrdb\fB, const char *\fIparams\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIparams\fR' specifies the string of the tuning parameters.  If it is `NULL', it is not used.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbvanish' is used in order to remove all records of a remote database object.
.PP
.RS
.br
\fBbool tcrdbvanish(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbcopy' is used in order to copy the database file of a remote database object.
.PP
.RS
.br
\fBbool tcrdbcopy(TCRDB *\fIrdb\fB, const char *\fIpath\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpath\fR' specifies the path of the destination file.  If it begins with `@', the trailing substring is executed as a command line.
.RE
.RS
If successful, the return value is true, else, it is false.  False is returned if the executed command returns non\-zero code.
.RE
.RS
The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress.  So, this function is useful to create a backup file of the database file.
.RE
.RE
.PP
The function `tcrdbrestore' is used in order to restore the database file of a remote database object from the update log.
.PP
.RS
.br
\fBbool tcrdbrestore(TCRDB *\fIrdb\fB, const char *\fIpath\fB, uint64_t \fIts\fB, int \fIopts\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpath\fR' specifies the path of the update log directory.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBROCHKCON' for consistency checking.
.RE
.RS
`\fIts\fR' specifies the beginning time stamp in microseconds.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbsetmst' is used in order to set the replication master of a remote database object.
.PP
.RS
.br
\fBbool tcrdbsetmst(TCRDB *\fIrdb\fB, const char *\fIhost\fB, int \fIport\fB, uint64_t \fIts\fB, int \fIopts\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIhost\fR' specifies the name or the address of the server.  If it is `NULL', replication of the database is disabled.
.RE
.RS
`\fIport\fR' specifies the port number.
.RE
.RS
`\fIts\fR' specifies the beginning timestamp in microseconds.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBROCHKCON' for consistency checking.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbsetmst2' is used in order to set the replication master of a remote database object with a simple server expression.
.PP
.RS
.br
\fBbool tcrdbsetmst2(TCRDB *\fIrdb\fB, const char *\fIexpr\fB, uint64_t \fIts\fB, int \fIopts\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIexpr\fR' specifies the simple server expression.  It is composed of two substrings separated by ":".  The former field specifies the name or the address of the server.  The latter field specifies the port number.  If the latter field is omitted, the default port number is specified.
.RE
.RS
`\fIts\fR' specifies the beginning timestamp in microseconds.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBROCHKCON' for consistency checking.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbrnum' is used in order to get the number of records of a remote database object.
.PP
.RS
.br
\fBuint64_t tcrdbrnum(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
The return value is the number of records or 0 if the object does not connect to any database server.
.RE
.RE
.PP
The function `tcrdbsize' is used in order to get the size of the database of a remote database object.
.PP
.RS
.br
\fBuint64_t tcrdbsize(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
The return value is the size of the database or 0 if the object does not connect to any database server.
.RE
.RE
.PP
The function `tcrdbstat' is used in order to get the status string of the database of a remote database object.
.PP
.RS
.br
\fBchar *tcrdbstat(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
The return value is the status message of the database or `NULL' if the object does not connect to any database server.  The message format is TSV.  The first field of each line means the parameter name and the second field means the value.
.RE
.RS
Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbmisc' is used in order to call a versatile function for miscellaneous operations of a remote database object.
.PP
.RS
.br
\fBTCLIST *tcrdbmisc(TCRDB *\fIrdb\fB, const char *\fIname\fB, int \fIopts\fB, const TCLIST *\fIargs\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIname\fR' specifies the name of the function.  All databases support "put", "out", "get", "putlist", "outlist", and "getlist".  "put" is to store a record.  It receives a key and a value, and returns an empty list.  "out" is to remove a record.  It receives a key, and returns an empty list.  "get" is to retrieve a record.  It receives a key, and returns a list of the values.  "putlist" is to store records.  It receives keys and values one after the other, and returns an empty list.  "outlist" is to remove records.  It receives keys, and returns an empty list.  "getlist" is to retrieve records.  It receives keys, and returns keys and values of corresponding records one after the other.
.RE
.RS
`\fIopts\fR' specifies options by bitwise\-or: `RDBMONOULOG' for omission of the update log.
.RE
.RS
`\fIargs\fR' specifies a list object containing arguments.
.RE
.RS
If successful, the return value is a list object of the result.  `NULL' is returned on failure.
.RE
.RS
Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE

.SH TABLE EXTENSION
.PP
The function `tcrdbtblput' is used in order to store a record into a remote database object.
.PP
.RS
.br
\fBbool tcrdbtblput(TCRDB *\fIrdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, TCMAP *\fIcols\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpkbuf\fR' specifies the pointer to the region of the primary key.
.RE
.RS
`\fIpksiz\fR' specifies the size of the region of the primary key.
.RE
.RS
`\fIcols\fR' specifies a map object containing columns.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, it is overwritten.
.RE
.RE
.PP
The function `tcrdbtblputkeep' is used in order to store a new record into a remote database object.
.PP
.RS
.br
\fBbool tcrdbtblputkeep(TCRDB *\fIrdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, TCMAP *\fIcols\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpkbuf\fR' specifies the pointer to the region of the primary key.
.RE
.RS
`\fIpksiz\fR' specifies the size of the region of the primary key.
.RE
.RS
`\fIcols\fR' specifies a map object containing columns.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If a record with the same key exists in the database, this function has no effect.
.RE
.RE
.PP
The function `tcrdbtblputcat' is used in order to concatenate columns of the existing record in a remote database object.
.PP
.RS
.br
\fBbool tcrdbtblputcat(TCRDB *\fIrdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB, TCMAP *\fIcols\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpkbuf\fR' specifies the pointer to the region of the primary key.
.RE
.RS
`\fIpksiz\fR' specifies the size of the region of the primary key.
.RE
.RS
`\fIcols\fR' specifies a map object containing columns.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RS
If there is no corresponding record, a new record is created.
.RE
.RE
.PP
The function `tcrdbtblout' is used in order to remove a record of a remote database object.
.PP
.RS
.br
\fBbool tcrdbtblout(TCRDB *\fIrdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpkbuf\fR' specifies the pointer to the region of the primary key.
.RE
.RS
`\fIpksiz\fR' specifies the size of the region of the primary key.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbtblget' is used in order to retrieve a record in a remote database object.
.PP
.RS
.br
\fBTCMAP *tcrdbtblget(TCRDB *\fIrdb\fB, const void *\fIpkbuf\fB, int \fIpksiz\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIpkbuf\fR' specifies the pointer to the region of the primary key.
.RE
.RS
`\fIpksiz\fR' specifies the size of the region of the primary key.
.RE
.RS
If successful, the return value is a map object of the columns of the corresponding record.  `NULL' is returned if no record corresponds.
.RE
.RS
Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbtblsetindex' is used in order to set a column index to a remote database object.
.PP
.RS
.br
\fBbool tcrdbtblsetindex(TCRDB *\fIrdb\fB, const char *\fIname\fB, int \fItype\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
`\fIname\fR' specifies the name of a column.  If the name of an existing index is specified, the index is rebuilt.  An empty string means the primary key.
.RE
.RS
`\fItype\fR' specifies the index type: `RDBITLEXICAL' for lexical string, `RDBITDECIMAL' for decimal string, `RDBITTOKEN' for token inverted index, `RDBITQGRAM' for q\-gram inverted index.  If it is `RDBITOPT', the index is optimized.  If it is `RDBITVOID', the index is removed.  If `RDBITKEEP' is added by bitwise\-or and the index exists, this function merely returns failure.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbtblgenuid' is used in order to generate a unique ID number of a remote database object.
.PP
.RS
.br
\fBint64_t tcrdbtblgenuid(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
The return value is the new unique ID number or \-1 on failure.
.RE
.RE
.PP
The function `tcrdbqrynew' is used in order to create a query object.
.PP
.RS
.br
\fBRDBQRY *tcrdbqrynew(TCRDB *\fIrdb\fB);\fR
.RS
`\fIrdb\fR' specifies the remote database object.
.RE
.RS
The return value is the new query object.
.RE
.RE
.PP
The function `tcrdbqrydel' is used in order to delete a query object.
.PP
.RS
.br
\fBvoid tcrdbqrydel(RDBQRY *\fIqry\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RE
.PP
The function `tcrdbqryaddcond' is used in order to add a narrowing condition to a query object.
.PP
.RS
.br
\fBvoid tcrdbqryaddcond(RDBQRY *\fIqry\fB, const char *\fIname\fB, int \fIop\fB, const char *\fIexpr\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
`\fIname\fR' specifies the name of a column.  An empty string means the primary key.
.RE
.RS
`\fIop\fR' specifies an operation type: `RDBQCSTREQ' for string which is equal to the expression, `RDBQCSTRINC' for string which is included in the expression, `RDBQCSTRBW' for string which begins with the expression, `RDBQCSTREW' for string which ends with the expression, `RDBQCSTRAND' for string which includes all tokens in the expression, `RDBQCSTROR' for string which includes at least one token in the expression, `RDBQCSTROREQ' for string which is equal to at least one token in the expression, `RDBQCSTRRX' for string which matches regular expressions of the expression, `RDBQCNUMEQ' for number which is equal to the expression, `RDBQCNUMGT' for number which is greater than the expression, `RDBQCNUMGE' for number which is greater than or equal to the expression, `RDBQCNUMLT' for number which is less than the expression, `RDBQCNUMLE' for number which is less than or equal to the expression, `RDBQCNUMBT' for number which is between two tokens of the expression, `RDBQCNUMOREQ' for number which is equal to at least one token in the expression, `RDBQCFTSPH' for full\-text search with the phrase of the expression, `RDBQCFTSAND' for full\-text search with all tokens in the expression, `RDBQCFTSOR' for full\-text search with at least one token in the expression, `RDBQCFTSEX' for full\-text search with the compound expression.  All operations can be flagged by bitwise\-or: `RDBQCNEGATE' for negation, `RDBQCNOIDX' for using no index.
.RE
.RS
`\fIexpr\fR' specifies an operand exression.
.RE
.RE
.PP
The function `tcrdbqrysetorder' is used in order to set the order of a query object.
.PP
.RS
.br
\fBvoid tcrdbqrysetorder(RDBQRY *\fIqry\fB, const char *\fIname\fB, int \fItype\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
`\fIname\fR' specifies the name of a column.  An empty string means the primary key.
.RE
.RS
`\fItype\fR' specifies the order type: `RDBQOSTRASC' for string ascending, `RDBQOSTRDESC' for string descending, `RDBQONUMASC' for number ascending, `RDBQONUMDESC' for number descending.
.RE
.RE
.PP
The function `tcrdbqrysetlimit' is used in order to set the limit number of records of the result of a query object.
.PP
.RS
.br
\fBvoid tcrdbqrysetlimit(RDBQRY *\fIqry\fB, int \fImax\fB, int \fIskip\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
`\fImax\fR' specifies the maximum number of records of the result.  If it is negative, no limit is specified.
.RE
.RS
`\fIskip\fR' specifies the number of skipped records of the result.  If it is not more than 0, no record is skipped.
.RE
.RE
.PP
The function `tcrdbqrysearch' is used in order to execute the search of a query object.
.PP
.RS
.br
\fBTCLIST *tcrdbqrysearch(RDBQRY *\fIqry\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
The return value is a list object of the primary keys of the corresponding records.  This function does never fail.  It returns an empty list even if no record corresponds.
.RE
.RS
Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbqrysearchout' is used in order to remove each record corresponding to a query object.
.PP
.RS
.br
\fBbool tcrdbqrysearchout(RDBQRY *\fIqry\fB);\fR
.RS
`\fIqry\fR' specifies the query object of the database.
.RE
.RS
If successful, the return value is true, else, it is false.
.RE
.RE
.PP
The function `tcrdbqrysearchget' is used in order to get records corresponding to the search of a query object.
.PP
.RS
.br
\fBTCLIST *tcrdbqrysearchget(RDBQRY *\fIqry\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
The return value is a list object of zero separated columns of the corresponding records.
.RE
.RS
This function does never fail.  It returns an empty list even if no record corresponds.  Each element of the list can be treated with the function `tcrdbqryrescols'.  Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbqryrescols' is used in order to get columns of a record in a search result.
.PP
.RS
.br
\fBTCMAP *tcrdbqryrescols(TCLIST *\fIres\fB, int \fIindex\fB);\fR
.RS
`\fIres\fR' specifies a list of zero separated columns of the search result.
.RE
.RS
`\fIindex\fR' the index of a element of the search result.
.RE
.RS
The return value is a map object containing columns.
.RE
.RS
Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbqrysearchcount' is used in order to get the count of corresponding records of a query object.
.PP
.RS
.br
\fBint tcrdbqrysearchcount(RDBQRY *\fIqry\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
The return value is the count of corresponding records or 0 on failure.
.RE
.RE
.PP
The function `tcrdbqryhint' is used in order to get the hint string of a query object.
.PP
.RS
.br
\fBconst char *tcrdbqryhint(RDBQRY *\fIqry\fB);\fR
.RS
`\fIqry\fR' specifies the query object.
.RE
.RS
The return value is the hint string.
.RE
.RS
This function should be called after the query execution by `tcrdbqrysearch' and so on.  The region of the return value is overwritten when this function is called again.
.RE
.RE
.PP
The function `tcrdbmetasearch' is used in order to retrieve records with multiple query objects and get the set of the result.
.PP
.RS
.br
\fBTCLIST *tcrdbmetasearch(RDBQRY **\fIqrys\fB, int \fInum\fB, int \fItype\fB);\fR
.RS
`\fIqrys\fR' specifies an array of the query objects.
.RE
.RS
`\fInum\fR' specifies the number of elements of the array.
.RE
.RS
`\fItype\fR' specifies a set operation type: `RDBMSUNION' for the union set, `RDBMSISECT' for the intersection set, `RDBMSDIFF' for the difference set.
.RE
.RS
The return value is a list object of the primary keys of the corresponding records.  This function does never fail.  It returns an empty list even if no record corresponds.
.RE
.RS
If the first query object has the order setting, the result array is sorted by the order.  Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE
.PP
The function `tcrdbparasearch' is used in order to search records for multiple servers in parallel.
.PP
.RS
.br
\fBTCLIST *tcrdbparasearch(RDBQRY **\fIqrys\fB, int \fInum\fB);\fR
.RS
`\fIqrys\fR' specifies an array of the query objects.
.RE
.RS
`\fInum\fR' specifies the number of elements of the array.
.RE
.RS
The return value is a list object of zero separated columns of the corresponding records.
.RE
.RS
This function does never fail.  It returns an empty list even if no record corresponds.  Each element of the list can be treated with the function `tcrdbqryrescols'.  Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.
.RE
.RE

.SH SEE ALSO
.PP
.BR ttserver (1),
.BR tcrtest (1),
.BR tcrmttest (1),
.BR tcrmgr (1),
.BR ttutil (3)
